{extend name="public/base" /}

{block name="content"}
<div class="container-fluid">
    <div class="breadcrumb-wrapper row">
        <div class="col-12 col-lg-3 col-md-6">
            <h4 class="page-title">角色关联菜单</h4>
        </div>
        <div class="col-12 col-lg-9 col-md-6">
            <ol class="breadcrumb float-right">
                <li><a href="{:url('Manage/home')}">控制台</a></li>
                <li class="active"> / 角色关联菜单</li>
            </ol>
        </div>
    </div>
</div>

<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header border-bottom">
                    <h4>角色: {$roleInfo.name}</h4>
                </div>
                <div class="card-body">
                    <form action="{:url('Role/roleMenuDo')}" method="post">
                        <input type="hidden" name="role_id" value="{$roleInfo.id}">
                        <table class="table table-striped table-bordered table-hover">
                            <thead>
                            <tr>
                                <th></th>
                                <th>ID</th>
                                <th>菜单</th>
                                <th>链接</th>
                                <th>更新时间</th>
                            </tr>
                            </thead>
                            <tbody>
                            {volist name="menuDatas" id="menu"}
                            <tr>
                                <td>
                                    {if in_array($menu['id'], $hasMenu)}
                                    <input type="checkbox" name="menu_id[]" value="{$menu.id}" checked>
                                    {else/}
                                    <input type="checkbox" name="menu_id[]" value="{$menu.id}">
                                    {/if}
                                </td>
                                <td>{$menu.id}</td>
                                <td>{$menu.name}</td>
                                <td>{$menu.link}</td>
                                <td>{$menu.update_time}</td>
                            </tr>

                            {notempty name="menu.children"}
                            {volist name="menu.children" id="item"}
                            <tr>
                                <td>
                                    {if in_array($item['id'], $hasMenu)}
                                    <input type="checkbox" name="menu_id[]" value="{$item.id}" checked>
                                    {else/}
                                    <input type="checkbox" name="menu_id[]" value="{$item.id}">
                                    {/if}
                                </td>
                                <td>{$item.id}</td>
                                <td>{$item.name}</td>
                                <td>{$item.link}</td>
                                <td>{$item.update_time}</td>
                            </tr>
                            {/volist}
                            {/notempty}

                            {/volist}
                            </tbody>
                        </table>
                        <br>
                        <button type="submit" class="btn btn-common">保存关联</button>
                        <a href="{:url('Role/roleList')}" class="btn btn-light">返回角色列表</a>
                        <br><br><br>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<div class="text-center">
</div>

{/block}